﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Gw2MumbleLinkServer
{
    class WindowsStartup
    {
        public static bool Exists(string keyName)
        {
            try
            {
                Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
                string p = (string)key.GetValue(keyName);

                if (p != null)
                    return true;
            }
            catch { }

            return false;
        }

        public static void Add(string keyName, string value)
        {
            Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
            key.SetValue(keyName, value, Microsoft.Win32.RegistryValueKind.String);
        }

        public static void Add(string keyName, string path, string args)
        {
            Add(keyName, '"' + path + "\" " + args);
        }

        public static void Remove(string keyName)
        {
            Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run");
            key.DeleteValue(keyName);
        }
    }
}
